<template>
  <div class="query">
    <van-nav-bar
      title="托盘解绑"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <div style="margin-bottom: 10px; padding: 0 10px">
      <van-cell-group>
        <van-field
          v-model="location_name"
          label="库位码"
          size="large"
          clearable
          placeholder="请扫描当前库位码"
        />
      </van-cell-group>
    </div>
    <!-- <div style="margin: 10px 0; padding: 0 10px">
      <van-cell-group>
        <van-field
          v-model="object_name"
          label="dolly号"
          size="large"
          placeholder="请输入/扫描dolly二维码"
        />
      </van-cell-group>
    </div> -->
    <div style="margin: 0 15px">
      <van-button size="large" type="primary" @click="untie">确认解绑</van-button>
    </div>
  </div>
</template>

<script>
import { syncDelet } from "@/api/api";
import { Toast } from "vant";

export default {
  name: "LibraryLocationQuery",
  data: () => {
    return {
      location_name: "",
      object_name: "",
    };
  },
  watch: {},
  created() {},
  async mounted() {},
  destroyed: function () {},
  methods: {
    onClickLeft() {
      this.$router.replace("/home");
    },
    untie() {
      if (!this.object_name && !this.location_name) {
        Toast.fail("库位名称或dolly号不能同时为空");
        return;
      }
      const params = {
        data: [
          {
            object_name: this.object_name,
            location_name: this.location_name,
          },
        ],
        in_dispatch_type: 1,
      };
      syncDelet(params).then((res) => {
        console.log("untie==res", res, res.data);
        if (res.data.success_list.length > 0) {
          Toast.success("操作成功");
        }
      });
    },
  },
};
</script>

<style scoped>
.query {
  /* padding: 0 10px; */
  /* background: #eee; */
}
</style>
